/**
 * 
 */
package org.pdecodts.yasb.util;

import java.util.logging.Level;
import java.util.logging.Logger;



/**
 * @author xsipds
 *
 */
public class Asserter {
    public static void precondition (Logger logger , boolean condition, Class<Exception> ec , String message , long code) throws Exception {
        if (!condition) {
            
            String emessage = "Error " + code + "Precondition not observed : " + message ;
            logger.log(Level.WARNING, emessage) ;
            Exception e = ec.getConstructor(String.class).newInstance(emessage) ;
             throw e ;
        }
    }
    public static void postcondition (Logger logger , boolean condition, Class<Exception> ec , String message , long code) throws Exception {
        if (!condition) {
            
            String emessage = "Error " + code + "Postcondition not observed : " + message ;
            logger.log(Level.WARNING, emessage) ;
            Exception e = ec.getConstructor(String.class).newInstance(emessage) ;
             throw e ;
        }
    }
    public static void alert (Logger logger , boolean condition, String message , long code)  {
        if (!condition) {
            
            String emessage = "Warning " + code + "Postcondition not observed : " + message ;
            logger.log(Level.WARNING, emessage) ;
           
             
        }
    }
    
}
